import { default as request, cloud } from '@/framework/utils/request'

export default {
  // 用户列表
  getUserList: (data) => {
    return request({
      url: cloud.dqbasic + '/employee/list',
      method: 'post',
      data
    })
  },
  // 添加用户
  addUser: (data) => {
    return request({
      url: cloud.dqbasic + '/employee/add',
      method: 'post',
      data
    })
  },
  // 下载导入模板
  downloadTemplate: (params) => {
    return request({
      url: cloud.dqbasic + '/employee/downloadTemplate',
      method: 'get',
      params,
      responseType: cloud.dqbasic + '/arraybuffer'
    })
  },
  // 导入
  uploadFile: (data) => {
    return request({
      url: cloud.dqbasic + '/employee/uploadFile',
      method: 'post',
      data,
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    })
  },
  // 下载导入失败的数据
  downloadFailData: (data) => {
    return request({
      url: cloud.dqbasic + '/employee/downloadFailData',
      method: 'post',
      data
    })
  },
  // 全部导出
  exportFile: (data) => {
    return request({
      url: cloud.dqbasic + '/employee/exportAll',
      method: 'post',
      data,
      responseType: 'arraybuffer'
    })
  },
  // 选择导出
  exportSelect: (data) => {
    return request({
      url: cloud.dqbasic + '/employee/exportSelect',
      method: 'post',
      data,
      responseType: 'arraybuffer'
    })
  },
  // 获取用户权限
  getUserapps: (data) => {
    return request({
      url: cloud.dqbasic + '/employee/appList',
      method: 'post',
      data
    })
  },
  getUserDetail: (data) => {
    return request({
      url: cloud.dqbasic + '/employee/detail',
      method: 'post',
      data
    })
  },
  // 编辑
  updateUser: (data) => {
    return request({
      url: cloud.dqbasic + '/employee/update',
      method: 'post',
      data
    })
  },
  // 编辑保存
  updateSuccess: (data) => {
    return request({
      url: cloud.dqbasic + '/employee/updateEmployeeSet',
      method: 'post',
      data
    })
  },
  // 查看用户已授权及可授权应用
  queryUserAppHasAuthorized: (data) => {
    return request({
      url: cloud.dqbasic + '/employee/queryUserAppHasAuthorized',
      method: 'post',
      data
    })
  },
  // 保存用户已授权应用，并分配默认账号
  updateUserAppPermission: (data) => {
    return request({
      url: cloud.dqbasic + '/addAppAuthority',
      method: 'post',
      data
    })
  },
  // 查询用户已授权的应用
  getUserAppPermission: (data) => {
    return request({
      url: cloud.dqbasic + '/employee/getUserAppPermission',
      method: 'post',
      data
    })
  },
  // 获取账号列表
  getAccountList: (data) => {
    return request({
      url: cloud.dqbasic + '/account/list',
      method: 'post',
      data
    })
  },
  // 启用账号
  onAccount: (data) => {
    return request({
      url: cloud.dqbasic + '/account/enable',
      method: 'post',
      data
    })
  },
  // 禁用账号
  offAccount: (data) => {
    return request({
      url: cloud.dqbasic + '/account/disable',
      method: 'post',
      data
    })
  },
  // 更新用户权限
  updateUserapps: (data) => {
    return request({
      url: cloud.dqbasic + '/employee/addAppAuthority',
      method: 'post',
      data
    })
  },
  // 修改用户密码
  changeUserpw: (data) => {
    return request({
      url: cloud.dqbasic + '/employee/changePwd',
      method: 'post',
      data
    })
  },
  // 重置用户密码
  resetUserpw: (data) => {
    return request({
      url: cloud.dqbasic + '/employee/resetPwd',
      method: 'post',
      data
    })
  },
  // 改变状态
  // 启用
  enAble: (data) => {
    return request({
      url: cloud.dqbasic + '/employee/enable',
      method: 'post',
      data
    })
  },
  // 禁用
  disAble: (data) => {
    return request({
      url: cloud.dqbasic + '/employee/disable',
      method: 'post',
      data
    })
  },
  // 改变锁定
  lockUser: (data) => {
    return request({
      url: cloud.dqbasic + '/employee/lock',
      method: 'post',
      data
    })
  },
  unlockUser: (data) => {
    return request({
      url: cloud.dqbasic + '/employee/unlock',
      method: 'post',
      data
    })
  },
  // 迁移用户
  flyUser: (data) => {
    return request({
      url: cloud.dqbasic + '/employee/fly',
      method: 'post',
      data
    })
  },

  // 删除用户
  deleteUser: (data) => {
    return request({
      url: cloud.dqbasic + '/employee/delete',
      method: 'post',
      data
    })
  },
  // 注销用户列表
  getDeldteUserList: (data) => {
    return request({
      url: cloud.dqbasic + '/cancellationEmployee/list',
      method: 'post',
      data
    })
  },
  // 注销用户恢复
  recoverDeldteUser: (data) => {
    return request({
      url: cloud.dqbasic + '/cancellationEmployee/recover',
      method: 'post',
      data
    })
  },
  // 彻底删除用户
  deleteUsercComplete: (data) => {
    return request({
      url: cloud.dqbasic + '/cancellationEmployee/delete',
      method: 'post',
      data
    })
  },
  // 获取应用列表
  getAppList: (data) => {
    return request({
      url: cloud.manage + '/sysApp/list',
      method: 'post',
      data
    })
  }

}
// 用户自助中心 -- 个人信息
export function getUserInfoByToken(data) {
  return request({
    url: cloud.dqbasic + '/unifyLogin/getUserInfoByToken',
    method: 'post',
    data
  })
}

